#ifndef __MEDIA_PLAYER_API_H_
#define __MEDIA_PLAYER_API_H_


//#define MP_DEBUG  libc_printf
#define MP_DEBUG(...)	

//#define FS_ROOT_DIR "/mnt"
char *fs_get_cur_root_name();
void fs_set_cur_root_name(char *root_name);

#define FS_ROOT_DIR fs_get_cur_root_name()


#define MAX_FILE_NUMBER				1000
#define PLAY_LIST_LIMIT_NUMBER			100 //user can change it to increase the fav list num, must <MAX_FILE_NUMBER

#define MAX_FILE_NAME_SIZE				1024
#define MAX_DIR_NAME_SIZE				MAX_FILE_NAME_SIZE
#define FULL_PATH_SIZE					(MAX_DIR_NAME_SIZE + MAX_FILE_NAME_SIZE + 1)


typedef void* FileListHandle;
typedef void* PlayListHandle;
typedef void (*filecopy_callback)(unsigned long percent);


//prime numbers between 0~255 means file type, and some of them multiply to be mediatype
//primes:	2	3	5	7	11	13	17	19	23	29	31	37	41	43	47	53	59	61
//67	71	73	79	83	89	97	101	103	139	149	151	157	163	167	173	179	181	191	193	197	199
//211	223	227	229	233	239	241	251

typedef enum
{ 
	F_DIR =	0,
	F_UNKOWN =	1,
	F_BMP =	2,
	F_MP3 =	3,
	F_JPG =	5,
	F_TXT =	7,
	F_BYE1 =	11,
	F_OGG = 13,
	F_MPG = 17,
	F_MPEG = 19,
	F_FLC = 29,
	F_WAV = 31,
	F_PCM = 37,

	F_ALL=	255,
}FileType; //valid types arranged be alphabet


typedef enum
{
	STORAGE_TYPE_USB,
	STORAGE_TYPE_SD,
	STORAGE_TYPE_HDD,
	STORAGE_TYPE_SATA,
	
	
	STORAGE_TYPE_ALL
}StorageDeviceType;



typedef struct
{
	char				name[MAX_FILE_NAME_SIZE];
	char				path[MAX_DIR_NAME_SIZE];
	FileType			filetype;
	char				in_play_list;
	unsigned int		size;
}FileInfo, *pFileInfo;	//info for ui show

typedef enum
{
	MUSIC_FILE_LIST,
	IMAGE_FILE_LIST,
	VIDEO_FILE_LIST,
	DIR_FILE_LIST,
	RAW_FILE_LIST,
	DLNA_FILE_LIST,

	MEDIA_PLAYER_FILE_LIST_NUMBER,
}FileListType;

typedef enum
{
	SORT_RAND=0,
	SORT_NAME, 
	SORT_DATE,
	SORT_SIZE,
	SORT_FAV,
}FileListSortType;


typedef enum
{
	MUSIC_PLAY_LIST,
	IMAGE_PLAY_LIST,
	VIDEO_PLAY_LIST,
	MIXED_PLAY_LIST,
}PlayListType;

typedef enum
{
	PlAY_LIST_SEQUENCE,
	PLAY_LIST_REPEAT,
	PLAY_LIST_RAND,
	PLAY_LIST_ONE,
	PLAY_LIST_NONE,
}PlayListLoopType;

typedef struct _DEC_CHAPTER_INFO
{
    DWORD nb_chapter;           /* number of chapters */
    INT32 cur_chapter;          /* current chapter */
    INT32 cur_start_time;       /* current chapter start time in second */
    INT32 cur_end_time;         /* current chapter end time in second */
    char  cur_title[10];        /* current chapter title name */
    INT32 dst_chapter;          /* current chapter */
    INT32 dst_start_time;       /* current chapter start time in second */
    INT32 dst_end_time;         /* current chapter end time in second */

    UINT32 reserved;            /* reserved */
}DEC_CHAPTER_INFO, *PDEC_CHAPTER_INFO;

typedef struct
{
	char VideoDec[10]; //the name of the video codec. For now, we support below video codec:
	                   //"mp43", "XIV1", "XIV2", "XVID", "unknown"
	char AudioDec[10]; //the name of the audio codec. For now, we support below audio codec:
	                   //"PCM", "MP3", "AC3", "DTS", "unknown"
	DWORD AudioStreamNum; //The audio track number in the media stream
	DWORD SubStreamNum; //The subtitle stream number in the media stream
	DWORD TotalFrameNum; //The total frame number of the media stream
	DWORD FramePeriod; //The frame period of the media stream
	DWORD TotalTime; //Total play time of the media stream
	int   width; //The width of the media stream. The maximum width the video decoder can support is 720.
	int   height; //The height of the media stream. The maximum height the video decoder can support is 576.
	DWORD VideoBitrate;
	DWORD AudioBitrate;
	DWORD AudioChannelNum;
	UINT32 fsize;
	INT32 AudioSampleRate;
	INT32 video_codec_tag;
	INT32 cur_audio_stream_id;
    INT32 cur_sub_stream_id;

	INT32 cur_prog_id;

	DWORD ProgNum;
    DWORD dwProgIndex;
	BYTE byCAFree;
	CHAR acProvideName[33];
	CHAR acProgName[33];
    DWORD dw_detail_flag;
}fileinfo_video, *p_fileinfo_video;


//RET_CODE media_player_init(PeConfig *pe_config);
void media_player_release();
int get_stroage_device_number(StorageDeviceType DeviceType);
RET_CODE get_current_stroage_device(StorageDeviceType DeviceType, char *device_array, unsigned char *device_array_size);

void mp_set_fav_list(UINT32 in);
FileListHandle create_file_list(FileListType type);
void delete_file_list(FileListHandle handle);
RET_CODE sort_file_list(FileListHandle handle, FileListSortType sort_type);
RET_CODE 	get_file_from_file_list(FileListHandle handle, unsigned short index, pFileInfo pinfo);
RET_CODE 	get_file_from_file_list2(FileListHandle handle, unsigned short index, pFileInfo pinfo);
RET_CODE 	get_file_list_info(FileListHandle handle, unsigned int *dir_number, unsigned int *file_number, char* current_path);
RET_CODE delete_files_from_file_list(FileListHandle handle, unsigned int *index_array, unsigned int index_array_size);
RET_CODE move_files_from_file_list(FileListHandle handle, unsigned int *index_array, unsigned int index_array_size, char* destination_path);
RET_CODE copy_files_from_file_list(FileListHandle handle, unsigned int source_file_index, char* destination_path, int flag, void* callback);
RET_CODE make_folders_in_file_list(FileListHandle handle, char* folder_name);
RET_CODE read_folder_to_file_list(FileListHandle handle, char *dirpath);
RET_CODE read_folder_to_file_list2(FileListHandle handle, char *dirpath);
void check_files_in_play_list(FileListHandle handle, PlayListHandle play_list_handle, char *if_all_in_play_list);
RET_CODE file_list_change_device(FileListHandle handle, char* devicename);
RET_CODE 	register_file_list_filter(char *name_array, unsigned int name_array_size);



#endif
